package com.mxpio.erp.mes.listener;

import com.mxpio.erp.common.mes.entity.MesScanInfo;
import com.mxpio.erp.common.mes.service.MesScanInfoService;
import com.mxpio.erp.mes.event.ScanAfterSaveInfoEvent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

@Component
public class ScanAfterSaveInfoListener implements ApplicationListener<ScanAfterSaveInfoEvent> {

    @Autowired
    private MesScanInfoService infoService;

    @Override
    @Async
    public void onApplicationEvent(ScanAfterSaveInfoEvent event) {
        MesScanInfo scanInfo = (MesScanInfo) event.getSource();
        infoService.save(scanInfo);
    }
}
